import { BetaSchemaForm } from '@ant-design/pro-form'
import { PageContainer } from '@ant-design/pro-layout'
import { useAxiosWebGet, useAxiosWebPost } from '@sker/sdk'
import { renderAdminPage } from '@sker/ui'
import { Form } from 'antd'
import { useEffect } from 'react'
export const AccountPage: React.FC<{}> = ({ }) => {
    const { fetch: getSetting } = useAxiosWebGet('imeepos/core/addon/setting')
    const { fetch: saveSetting } = useAxiosWebPost('imeepos/core/addon/setting')
    const [form] = Form.useForm()
    useEffect(() => {
        getSetting({ name: '@imeepos/tmap' }).then(res => res.data).then(res => form.setFieldsValue(res))
    }, [])
    return <PageContainer title={'腾讯地图参数设置'}>
        <BetaSchemaForm
            columns={[
                { title: 'Key', dataIndex: 'key' },
                { title: 'Secret key（ SK ）：', dataIndex: 'secret', valueType: 'textarea' }
            ]}
            form={form}
            onFinish={async values => {
                saveSetting({
                    name: '@imeepos/tmap',
                    setting: values
                })
                console.log({ values })
            }} />
    </PageContainer>
}
renderAdminPage(AccountPage, 'imeepos/tmap/web/setting')
